package team.fivez.defaultmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import team.fivez.defaultmanage.domain.Approver;
import team.fivez.defaultmanage.domain.Result;
import team.fivez.defaultmanage.service.ApproverService;
import team.fivez.defaultmanage.utils.Utils;

import java.security.NoSuchAlgorithmException;

@CrossOrigin
@RestController
@RequestMapping("/approver")
public class ApproverController {

    private final ApproverService approverService;

    @Autowired
    public ApproverController(ApproverService approverService) {
        this.approverService = approverService;
    }

    @PostMapping("/login")
    public Result login(@RequestBody Approver approver) throws NoSuchAlgorithmException {
        System.out.println(approver);
        return Utils.success(approverService.login(approver));
    }

    @PostMapping("/register")
    public Result register(@RequestBody Approver approver) throws NoSuchAlgorithmException {
        System.out.println(approver);
        return Utils.success(approverService.register(approver));
    }



}
